﻿Ext.define('app.prm.project.Index', {
    extend: 'Ext.grid.Panel',
    title: localize('ProjectList'),
    border: false,
    tbar: [],
    viewConfig: {
        enableTextSelection: true //可以复制单元格文字
    },
    controller: 'project',
    requires: ['app.prm.project.ProjectController', 'app.prm.project.ViewModel'],
    viewModel: {
        type: 'projectModel'
    },
    initComponent: function () {
        var me = this;

        me.tbar = [
            { text: localize('Add'), glyph: 0xf067, bind: { hidden: '{hasAdd}' }, handler: 'onAdd' },
            { text: "申请查看", glyph: 0xf0f0, handler: 'onApply' },
            '->',
            {
                text: '查询', glyph: 0xf002, menu:
                {
                    xtype: 'menu',
                    plain: true,
                    items: Ext.create("app.prm.project.Search")
                }
            },
            {
                text: localize('Refresh'),
                glyph: 0xf021, handler: 'onStartSearch'
            }
        ];
        me.store = Ext.create("app.ux.PagePrmStore", { url: '/api/services/app/project/GetAll', autoLoad: false });

        me.pagingBar = Ext.create({
            xtype: 'pagingtoolbar',
            store: me.store,   // same store GridPanel is using
            dock: 'bottom',
            displayInfo: true
        });
        me.dockedItems = [me.pagingBar]

        me.callParent();
    },
    forceFit: false,
    columns: [
        {
            xtype: 'actioncolumn',
            width: 50,
            header: localize('Operating'),
            items: [
            {
                icon: '/Content/images/page_go.png',
                tooltip: '详细',
                handler: 'onEditProject'
            }]
        },
        {
            text: "#", xtype: 'rownumberer', width: 50
        },
        { header: localize('ProjectName'), dataIndex: 'projectName' },
        { header: localize('ProjectNo'), dataIndex: 'projectNo' },
        { header: localize('ProductNo'), dataIndex: 'productNo' },
        { header: localize('Customer'), dataIndex: 'customer' },
        { header: '项目经理', dataIndex: 'pm' },
        //{ header: localize('CustomerCode'), dataIndex: 'customeCode' },
        { header: '事业部', dataIndex: 'business' },
        { header: localize('RdCenter'), dataIndex: 'rdCenter' },
        { header: localize('Laboratory'), dataIndex: 'laboratory' },
        { header: localize('PlanStartDate'), dataIndex: 'planStartDate' },
        { header: localize('PlanEndDate'), dataIndex: 'planEndDate' },
        { header: localize('RequiredCompleteDate'), dataIndex: 'targetEndDate' },
        { header: '项目状态', dataIndex: 'projectStatus' }
    ],
    listeners: {
        afterrender: 'onInit',
        rowdblclick: 'onDbClick'
    }
})